<?php

if( !defined('classHeader') )
{
  	define('classHeader', 'true', false);
	include_once('databaseData_class.php');
	include_once('User_class.php');
	include_once('Department_class.php');
	include_once('User_Perms_class.php');
	include_once('FileData_class.php');
	include_once('Department_class.php');
	include_once('Dept_Perms_class.php');
	include_once('UserPermission_class.php');
	
	function advanceCombineArrays($hi_priority_array, $hi_postfix, $low_priority_array, $low_postfix)
	{
		$user_rights = array();
		$k = 0;
		$foundFlag = false;

		for($i = 0; $i<sizeof($low_priority_array); $i++)
			{	$user_rights[$i] = array($low_priority_array[$i], $low_postfix);	}
		
		$k = sizeof($user_rights);
		for($m = 0; $m<sizeof($hi_priority_array); $m++)
		{
			for($u = 0; $u<sizeof($user_rights); $u++)
			{	
				if($user_rights[$u][0] == $hi_priority_array[$m] and $hi_postfix!='NULL' )
				{
					$user_rights[$u][1] = $hi_postfix;
					$foundFlag = true;
				}
				if($user_rights[$u][0] == $hi_priority_array[$m][0] and $hi_postfix =='NULL')
				{
					$user_rights[$u][1] = $hi_priority_array[$m][1];
					$foundFlag = true;
				}
	
			}
			if($foundFlag==false & $hi_postfix != 'NULL')
			{
					$user_rights[$k++]= array($hi_priority_array[$m], $hi_postfix);
			}
			if($foundFlag==false & $hi_postfix == 'NULL')
			{
					$user_rights[$k++]= $hi_priority_array[$m];
			}
			$foundFlag = false;
		}
		return $user_rights;
	}
	function combineArrays($high_priority_array, $low_priority_array)
	{
		$found = false;
		$result_array = array();
		$result_array = $high_priority_array;
		$result_array_index = sizeof($high_priority_array);
		for($l = 0 ; $l<sizeof($low_priority_array); $l++)
		{
			for($r = 0; $r<sizeof($result_array); $r++)
			{
				if($result_array[$r] == $low_priority_array[$l] && $high_priority_array[$r] == true)
				{
					$r = sizeof($result_array);
					$found = true;
				}
			}
			if(!$found)
			{
				$result_array[$result_array_index++] = $low_priority_array[$l];
			}
			$found = false;
		}
		return $result_array;
	}
	
}
?>
